package com.rw.coco.handler.message.reply;

import com.rw.coco.handler.message.event.CocoMessageEvent;
import com.rw.coco.handler.message.event.CocoPrivateMessageEvent;

public abstract class PrivateReplyHandler implements ReplyHandler {
    /**
     * 触发的条件
     */
    @Override
    public boolean trigger(CocoMessageEvent cocoMessageEvent) {
        if (cocoMessageEvent instanceof CocoPrivateMessageEvent) {
            CocoPrivateMessageEvent privateEvent = (CocoPrivateMessageEvent) cocoMessageEvent;
            return privateTrigger(privateEvent);
        }
        return false;
    }

    /**
     * 触发逻辑
     */
    @Override
    public void handler(CocoMessageEvent cocoMessageEvent) {
        if (cocoMessageEvent instanceof CocoPrivateMessageEvent) {
            CocoPrivateMessageEvent privateEvent = (CocoPrivateMessageEvent) cocoMessageEvent;
            privateHandler(privateEvent);
        }
    }

    protected abstract boolean privateTrigger(CocoPrivateMessageEvent privateEvent);

    protected abstract void privateHandler(CocoPrivateMessageEvent privateEvent);
}
